package hy.controller;

import hy.beans.AjaxResult;
import hy.beans.Emp;
import hy.dao.EmpDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/sys")
@RestController
public class EmpCtrl {
    @Autowired
    EmpDao dao;

    @PostMapping("/emp")
    public AjaxResult addEmp(@RequestBody Emp e){
        System.out.println("----------------------------"+e);
        Integer rs = dao.insertEmp(e);
        AjaxResult r = new AjaxResult();
        r.setSuccess(rs>0);
        return r;
    }

    @DeleteMapping("/emp/{id}")
    public AjaxResult deleteEmpById(@PathVariable Integer id){
       return new AjaxResult(dao.deleteEmpById(id)>0,null);
    }
}